package com.pine.dcts.core.impl;

import com.alibaba.datax.common.util.Configuration;
import com.pine.dcts.core.AbstractPluginConfigHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @author xiaoyuan
 * @create 2020/12/10 20:47
 **/
@Component
public class MysqlReaderConfigHandler extends AbstractPluginConfigHandler {

    private static final String QUERY_MODEL = "queryModel";

    private static final String QUERY_SQL = "connection[0].querySql";

    private static final String TABLE = "connection[0].table";
    private static final String COLUMN = "column";
    private static final String WHERE = "where";

    private static final String FETCH_SIZE = "fetchSize";

    @Override
    public void cleanPlguinConfig(Configuration configuration) {

//        String queryModel = configuration.getString(QUERY_MODEL);
//        if (StringUtils.isNotEmpty(queryModel)) {
//            if ("table".equalsIgnoreCase(queryModel)) {
//                configuration.remove(QUERY_SQL);
//                return;
//            }
//            configuration.remove(TABLE);
//            configuration.remove(COLUMN);
//            configuration.remove(WHERE);
//        }
//        if(configuration.get(FETCH_SIZE)!=null){
//            configuration.remove(FETCH_SIZE);
//        }

    }

    @Override
    public boolean support(String type) {
        return "mysqlreader".equalsIgnoreCase(type);
    }
}
